package cn.gson.oasys.controller.AoaTaskListController;

import cn.gson.oasys.pojo.AoaTaskList;
import cn.gson.oasys.service.AoaTaskListService.AoaTaskListService;
import cn.gson.oasys.service.AoaTaskLoggerService.AoaTaskLoggerService;
import cn.gson.oasys.service.AoaTaskUserServicelx.AoaTaskUserService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by 刘雯欣 on 2020/11/30.
 * 处理任务管理
 */
@Controller  //如何加事务就给Controller加@Transactional
public class AoaTaskListController {

    @Resource
    private AoaTaskListService aoaTaskListService;

    @Resource
    private AoaTaskLoggerService aoaTaskLoggerService;

    @Resource
    private AoaTaskUserService aoaTaskUserService;


    //1：进入任务管理器后查询所有任务列表 by 刘雯欣 on 2020/11/30.123
    @RequestMapping("findAllAoaTaskList")
    @ResponseBody
    public Object findAllAoaTaskList(){
        return aoaTaskListService.findAllAoaTaskList();
    }

    //2：查询所有列表之后进行按列表模糊查询 by 刘雯欣 on 2020/11/30.
    @RequestMapping("likefindAllAoaTaskList")
    @ResponseBody
    public Object likefindAllAoaTaskList(String title){
        System.out.println(aoaTaskListService.likefindAllAoaTaskList(title));
       return aoaTaskListService.likefindAllAoaTaskList(title);
    }

    //3：用于新增 by 刘雯欣 on 2020/11/30.
    //修改
    @ApiOperation(value = "新增任务",notes="AoaTaskList传入对象")
    @ApiImplicitParam(dataType = "AoaTaskList",name = "record",value = "增加书籍",
            required = true,paramType ="AoaTaskList" )
    @RequestMapping("insertSelective")
    @ResponseBody
    public int insertSelective(AoaTaskList record){
        System.out.println(aoaTaskListService.insertSelective(record));
        return aoaTaskListService.insertSelective(record);
    }

    //4: 删除 by 刘雯欣 on 2020/12/01 在做主表删除之前要完成两个关联表的删除
    @RequestMapping("delect1etterone")
    @ResponseBody
    public int delect1etterone(Long taskId){
        return aoaTaskLoggerService.delectByTaskIdc(taskId);
    }
    @RequestMapping("delect1ettertwo")
    @ResponseBody
    public int delect1ettertwo(Long taskId){
        System.out.println(aoaTaskUserService.delectByTaskIdc(taskId)+"听说");
        return aoaTaskUserService.delectByTaskIdc(taskId);
    }
    @RequestMapping("delectbig")
    @ResponseBody
    public int delectbig(Long taskId){
        return aoaTaskListService.deleteByPrimaryKey(taskId);
    }

    //5: 修改任务 by 刘雯欣 on 2020/12/01
    //修改
    @RequestMapping("updateByPrimaryKeySelective")
    @ResponseBody
    public int updateByPrimaryKeySelective(AoaTaskList record){
        return aoaTaskListService.updateByPrimaryKeySelective(record);
    }

    //访问页面任务管理的Controller
    @RequestMapping("indextwo")
    public String haha(){
        return "renwuguanli/rwglzhuyemian";
    }

}
